//
//  CTMediator+SEAlterAction.m
//  SleepingElf
//
//  Created by karong on 2023/6/21.
//

#import "CTMediator+SEAlterAction.h"
/// 類名
NSString * const SECTMediatorTargetAlter = @"Alter";
/// 方法名
NSString * const SECTMediatorActionShowAlter = @"showAlter";
NSString * const SECTMediatorActionShowTextFieldAlter = @"showTextFieldAlter";

@implementation CTMediator (GRAlterAction)

- (UIViewController *)ct_showAlterWithTitle:(NSString *)title content:(NSString *)content confirm:(NSString *)confirm confirmHandle:(EmptyBlock)confirmHandle cancel:(NSString *)cancel {
    NSMutableDictionary * params = [NSMutableDictionary new];
    if (!SEIsNullOrEmpty(title))params[@"titleStr"] = title;
    if (!SEIsNullOrEmpty(content))params[@"content"] = content;
    if (!SEIsNullOrEmpty(confirm))params[@"confirm"] = confirm;
    if (!SEIsNullOrEmpty(cancel))params[@"cancel"] = cancel;
    if (confirmHandle)params[@"confirmHandle"] = confirmHandle;
    return [self performTarget:SECTMediatorTargetAlter
                        action:SECTMediatorActionShowAlter
                        params:params
             shouldCacheTarget:YES];
}

- (UIViewController *)ct_showTFAlterWithTitle:(NSString *)title content:(NSString *)content placeholderStr:(NSString *)placeholderStr maxWordCount:(NSInteger)maxWordCount confirm:(NSString *)confirm confirmHandle:(StringBlock)confirmHandle cancel:(NSString *)cancel {
    NSMutableDictionary * params = [NSMutableDictionary new];
    if (!SEIsNullOrEmpty(title))params[@"titleStr"] = title;
    if (!SEIsNullOrEmpty(content))params[@"content"] = content;
    if (!SEIsNullOrEmpty(confirm))params[@"confirm"] = confirm;
    if (!SEIsNullOrEmpty(cancel))params[@"cancel"] = cancel;
    if (confirmHandle)params[@"confirmHandle"] = confirmHandle;
    params[@"maxWordCount"] = @(maxWordCount);
    params[@"placeholderStr"] = SEEmptyStr(placeholderStr);
    return [self performTarget:SECTMediatorTargetAlter
                        action:SECTMediatorActionShowTextFieldAlter
                        params:params
             shouldCacheTarget:YES];
}

@end
